#ifndef YEPXML_TESTREADING_HPP
#define YEPXML_TESTREADING_HPP
#include <iostream>
#include <cstdlib>
#include "YepXML.hpp"
#include <sstream>
#include <fstream>

using namespace std;
using namespace yxml;

static const char fileContent[] = "<?xml version=\"1.0\" standalone=\"yes\" encoding=\"UTF-8\" ?>\n"
                                  "<Arvore altura = \"30 m\" idade = \"100 anos\">\n"
                                  "  <galho altura = \"15 m\">\n"
                                  "    Eu tenho folhas!\n"
                                  "     Eu tenho  folhas!\n"
                                  "    <folha/>\n"
                                  "    <folha/>\n"
                                  "  </galho>\n"
                                  "  <galho>\n"
                                  "    <folha/>\n"
                                  "    <!--E tem mais uma-->\n"
                                  "    <folha/>\n"
                                  "  </galho>\n"
                                  "</Arvore>";

istream& getFile()
{
    static stringstream stream( fileContent );
    static ifstream stream2("D:\\dev\\c++\\tests\\GymUFPA\\media\\scenes\\ogre.scene");
    return stream2;
}

int testReading()
{
    Document doc( "" );
    istream& in =getFile();
    try
    {
        Reader reader( in );
        reader.textPolicy(Reader::Policy::NOTHING);
        reader.read( doc );
    }
    catch( const ReadingError &error)
    {
        cerr << "Line " << error.errorLine() << ": " << error.error() << "; pos:" << error.ccount() << endl;
        return EXIT_FAILURE;
    }
    HierarchicalWritterDeprecated writter(cout);
    writter.write(doc);
//    cout << fileContent;
    return EXIT_SUCCESS;
}

#endif // YEPXML_TESTREADING_HPP

